﻿using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace ServerUtils.Test
{
    [TestClass]
    public class OperationResultTest
    {
        [TestMethod]
        public void GivenSucceedOperationResult_MessagePropertyMustBeNull()
        {
            var actual = OperationResult.Succeed;

            Assert.IsNull(actual.Message);
        }

        [TestMethod]
        public void GivenSucceedOperationResult_ResultTypePropertyMustBeSucceed()
        {
            var actual = OperationResult.Succeed;

            Assert.AreEqual(OperationResultType.Succeed, actual.ResultType);
        }

        [TestMethod]
        public void GivenFailedOperationResult_MessagePropertyMustBeSet()
        {
            var actual = OperationResult.Failed("a text {0}", "with parameter");

            Assert.AreEqual("a text with parameter", actual.Message);
        }

        [TestMethod]
        public void GivenFailedOperationResult_ResultTypePropertyMustBeFailed()
        {
            var actual = OperationResult.Failed("a text");

            Assert.AreEqual(OperationResultType.Failed, actual.ResultType);
        }

        [TestMethod]
        public void GivenErrorOperationResult_MessagePropertyMustBeSet()
        {
            var actual = OperationResult.Error("a text {0}", "with parameter");

            Assert.AreEqual("a text with parameter", actual.Message);
        }

        [TestMethod]
        public void GivenErrorOperationResult_ResultTypePropertyMustBeError()
        {
            var actual = OperationResult.Error("a text");

            Assert.AreEqual(OperationResultType.Error, actual.ResultType);
        }

        [TestMethod]
        public void GivenOperationResult_ToStringMustBeOverrided()
        {
            var actual = new OperationResult { ResultType = OperationResultType.Failed, Message = "a text" };

            Assert.AreEqual("ResultType: Failed, Message: a text", actual.ToString());
        }
    }
}
